<template>
  <div class="wh" style="">
    <el-tree :data="treedata" show-checkbox node-key="id" :default-expanded-keys="[]" :default-checked-keys="dck"
       @check-change="ncheck" v-if="iftree">
    </el-tree>
  </div>
</template>

<script>
// import ToolItem from '@/components/map/tools/ToolItem.vue'

import _ from 'lodash'

let pickEntity = null
export default {
  name: '',
  components: {
    // ToolItem,
  },
  data() {
    return {
      dck: [],
      treedata: [],
      defaultProps: {
        label: 'label'
      },
      iftree: false,
    }
  },
  computed: {

  },
  // inject: ['activeTool','activeToolParent'],
  watch: {
  },
  mounted() {
    this._layers = {}
    earth.sceneTree.root.children.map(item => {
      if (_.has(item, 'title') && item.title == '基础图层') {
        item.children.map(iitem => {

          this.treedata.push({
            label: iitem.czmObject.name,
            id: iitem.czmObject.xbsjGuid
          })
          this._layers[iitem.czmObject.xbsjGuid] = iitem
          if ((_.has(iitem.czmObject, 'enabled') && iitem.czmObject.enabled)) {
            this.dck.push(iitem.czmObject.xbsjGuid)
          }
        })

        setTimeout(() => {
          this.iftree = true
        }, 0);

      }
    })
  },
  beforeDestroy() {
    this._disposers.forEach(d => d());
    this._disposers.length = 0;
  },
  methods: {
    ncheck(a,b,c){
      if (b) {
        
        this._layers[a.id].enabled = true
      }else{
        this._layers[a.id].enabled = false

      }
    },
    qingkongclick() {
      
    },
    closewindow(){
      this.qingkongclick()
    }
  },
}
</script>

<style lang="scss">

.el-tree{
  background-color: #0000!important;
  color: white;
}

.wh{
  width: 100%;
  height: 100%;
}

</style>
